<?php
namespace app\admin\controller;

class WeixinMenu extends Base{

	public function index(){

		parent::index('', $where, '', false);
		import('Tree', EXTEND_PATH, '.class.php');
		$tree = new \Tree($this->_list, 'menu_id', 'parent_id');
		$list = $tree->getTrees();
		$this->assign('list', $list);

		return $this->view();
	}
	public function add(){
		$list = model('WeixinMenu')->where(array('is_delete' => 0, 'status' => 1))->select();
		$this->assign('list', $list);
		
		return parent::add('');
	}
	public function edit(){
		$list = model('WeixinMenu')->where(array('is_delete' => 0, 'status' => 1))->select();
		$this->assign('list', $list);

		return parent::edit();
	}
	public function recycle(){
		return parent::recycle('', $where, '', false);
	}

	public function update_menu(){
		$where['is_delete'] = 0;
		$where['status']    = 1;
		$list  = db('WeixinMenu')->where($where)->order('order_id,menu_id desc')->select();
		$model = model('Weixin');
		if($model->set_menu($list)){
			$this->success('同步成功！', '');
		}else{
			$this->error('同步失败！' . $model->tips_info, '');
		}
	}

	public function user_list(){
		return parent::index('WeixinUser', '', '', false);
	}
}